import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaLocaleProvider, WeaPopoverHrm, WeaIntro, WeaTools } from 'ecCom';

const { Intro } = WeaIntro;
@inject('docAllDocStore')
@observer
class Home extends React.Component {
  constructor(props) {
    super(props);
    this.state = { needInstro: false };
    // 预先加载查询树
   // !this.props.location.query.outDoc && !sessionStorage.wea_Doc_hasShowIntro &&
   // props.docAllDocStore.getTreeDatas('Search', { viewcondition: 0, preLoad: true })
   //   .getTreeDatas('Search', { viewcondition: 1, preLoad: true })
   //   .getTreeDatas('Search', { viewcondition: 2, preLoad: true });
  }
  componentDidMount() {
	  if (!this.props.location.query.outDoc) {
		WeaTools.callApi('/api/doc/searchlist/getIntrostep', 'GET', {}).then((result) => {
			if (result) {
				this.setState({ needInstro: result.needIntro });
			}
		});
	  }
  }
  render() {
    const { needInstro } = this.state;
    return (
      <div style={{ height: '100%' }}>
        <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@d0wr79`} />
        {
          needInstro &&
          <Intro ecId={`${this && this.props && this.props.ecId || ''}_Intro@o360fz`} onReady={(intro) => {
            window.document_intro = intro;
          }}
          />
        }
        <iframe id="hiddenPreLoaderSingle" name="hiddenPreLoaderSingle" style={{ display: 'none' }} width="0" height="0" border="0" frameBorder="0" />
          <WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@5cved9`}>
            { this.props.children }
          </WeaLocaleProvider>
      </div>
    );
  }
}

export default Home;
